﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Wage_WageClearing : ATPages
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Function f = new Function();
        if (!IsPostBack)
        {
            
            ZSql js = new ZSql();
             hfxs.Value=Request.QueryString["moduid"].ToString();
             lblPath.Text = f.getModuleidAdd(Request["moduid"]);
             hfgetId.Value = Request.QueryString["WagesId"].ToString();
             hfgetTim.Value = Request.QueryString["WageDate"].ToString();
            cleaTime.Text = DateTime.Now.ToShortDateString();
            lblName.Text = Server.UrlDecode(Request.Cookies["user"].Values["name"]);
            WStaffSalary.Attributes["contentEditable"] = "false";
            WStaffPerformance.Attributes["contentEditable"] = "false";
            WYWage.Attributes["contentEditable"] = "false";
            WSWage.Attributes["contentEditable"] = "false";
            js.Open("select WagesId,WStaffId,WStaffName,WStaffSalary,WStaffPrice,WStaffPercentage,WStaffPerformance,WYWage,WSWage,WDiscount,WageDate,AuditUserName,convert(char(10),AuditDate,120) as AuditDate,department from CS_Wages where WagesId='" + hfgetId.Value + "' and WageDate='"+hfgetTim.Value+"'");
            if (js.m_table.Rows.Count > 0)
            {
                WStaffName.Text = js.m_table.Rows[0]["WStaffName"].ToString();
                WStaffSalary.Text = js.m_table.Rows[0]["WStaffSalary"].ToString().Substring(0, js.m_table.Rows[0]["WStaffSalary"].ToString().Length-2);
                department.Text = js.m_table.Rows[0]["department"].ToString();
                WStaffPercentage.Text = js.m_table.Rows[0]["WStaffPercentage"].ToString();
                WStaffPerformance.Text = js.m_table.Rows[0]["WStaffPerformance"].ToString().Substring(0, js.m_table.Rows[0]["WStaffPerformance"].ToString().Length-2);
                lblrq.Text = js.m_table.Rows[0]["WageDate"].ToString();
                WStaffPrice.Text = js.m_table.Rows[0]["WStaffPrice"].ToString().Substring(0, js.m_table.Rows[0]["WStaffPrice"].ToString().Length-2);
                WYWage.Text = js.m_table.Rows[0]["WYWage"].ToString().Substring(0, js.m_table.Rows[0]["WYWage"].ToString().Length-2);
                WSWage.Text = js.m_table.Rows[0]["WSWage"].ToString().Substring(0, js.m_table.Rows[0]["WSWage"].ToString().Length-2);
                Wkc.Text = js.m_table.Rows[0]["WDiscount"].ToString().Substring(0, js.m_table.Rows[0]["WDiscount"].ToString().Length-2);
            }
            else
            {
                Response.Write("<script>alert('员工工资还未有结算的数据');location.href=document.referrer</script>");
            }

        }
    }
 
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        ZSql bcupdate = new ZSql();

        bcupdate.Open("update CS_Wages set WStaffPercentage=" + Common.FormatParameter(WStaffPercentage.Text) + ", WStaffPrice=" + Common.FormatParameter(WStaffPrice.Text) + ",WDiscount=" + Common.FormatParameter(Wkc.Text) + ",WYWage=" + WYWage.Text + ",WSWage=" + WSWage.Text + ",EditDate='" + cleaTime.Text + "',EditUserName='" + lblName.Text + "' where WagesId='" + hfgetId.Value + "' and WageDate='" + hfgetTim.Value + "'");
        Response.Write("<script>window.location='ViewWages.aspx?moduid=" + Request["moduid"] + "';</script>");
 
    }
}
